* get coretool to work on macos under qmake.
* enhance coretool.
1. don't use stderr for coretool output. This avoids comingling of
real error messages with the coretool output.
2. disable the similartext heuristic with coretool. This heuristic,
which is enabled by default, was resulting in occasional mistranslations.
-#include <QList>
#include <QApplication>
+#include <QFile>
+#include <QList>
+#include <QTextStream>
#include "format.h"
#include "formatload.h"
+QTextStream* generate_output_stream;
+
int main(int argc, char** argv)
{
QApplication app(argc, argv);
+ QStringList qargs = QApplication::arguments();
+
QList<Format> formatList;
- return FormatLoad().getFormats(formatList) ? 0 : 1;
+
+ if (qargs.size() != 2) {
+ qFatal("Usage: %s output_file_name", qPrintable(qargs.at(0)));
+ }
+
+ QFile generate_output_file(qargs.at(1));
+ bool status = generate_output_file.open(QIODevice::WriteOnly);
+ if (!status) {
+ qFatal("Could not open %s for write!", qPrintable(qargs.at(1)));
+ }
+ generate_output_stream = new QTextStream(&generate_output_file);
+
+ bool fmtstatus = FormatLoad().getFormats(formatList);
+
+ generate_output_stream->flush();
+ generate_output_file.close();
+ delete generate_output_stream;
+
+ return fmtstatus ? 0 : 1;
}
# these strings.
#
CONFIG += console
+CONFIG -= app_bundle
QT -= gui
QT += core \
core_strings.depends = $(TARGET)
core_strings.depends += ../../gpsbabel
core_strings.commands = $(COPY_FILE) ../../gpsbabel $(DESTDIR)gpsbabel &&
-core_strings.commands += ./$(TARGET) 2>core_strings.h;
+core_strings.commands += ./$(TARGET) core_strings.h;
QMAKE_EXTRA_TARGETS += core_strings
QMAKE_DISTCLEAN += $(DESTDIR)gpsbabel
+# The line numbers are almost meaningless the way we generate corestrings.h, and we force everything to the same context.
+# With line numbers and the similartext heuristic enabled translations can be copied from an old message to a new message,
+# and marked as unfinished. The threshold for similar is low.
+# These will be used by the application, even though they really need to be checked.
+# Disable the similartext heuristic to avoid these mistranslations.
qtPrepareTool(LUPDATE, lupdate)
update.depends = core_strings.h
-update.commands = $$LUPDATE -locations absolute core.pro
+update.commands = $$LUPDATE -disable-heuristic similartext core.pro
QMAKE_EXTRA_TARGETS += update
qtPrepareTool(LRELEASE, lrelease)
#include "appname.h" // for appName
+#ifdef GENERATE_CORE_STRINGS
+extern QTextStream* generate_output_stream;
+#endif
+
//------------------------------------------------------------------------
static QString xlt(const QString& f)
{
#ifdef GENERATE_CORE_STRINGS
- qInfo().nospace() << "QT_TRANSLATE_NOOP(\"core\"," << f << ")";
+ *generate_output_stream << "QT_TRANSLATE_NOOP(\"core\",\"" << f << "\")" << Qt::endl;
#endif
return QCoreApplication::translate("core", f.toUtf8().constData());
}